window.onload=function(){

	$("#btn-in").click(function(){
		var phone=$("*[name='phone']").val();
		var password=$("*[name='password']").val();
		$.ajax({
			type:"post",
			url:"/ldss/user/login",
			async:false,
			data:{
				usertel:phone,
				userpasswd:md5(password)
			},
			dataType:"json",
			success: function (data) {
				if(data.success){
					if(data.flag==1){
						window.location.href="/ldss/html/boss/boss.html";
					}else if(data.flag==2){
						window.location.href="/ldss/html/manager/manager.html";
					}
					else if(data.flag==3){
						window.location.href="/ldss/html/waiter/waiter.html";
					}
					else if(data.flag==4){
						window.location.href="/ldss/html/barcounter/bar-counter.html";
					}
				}else{
					alert(data.message);
				}
			},
			error: function(){
				alert("请求出错");
			}
		})

	});

}
